package com.service.scheduling.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.service.dao.mapper.OtcOrderMapper;
import com.service.dao.model.OtcOrder;
import com.service.scheduling.service.OtcOrderDetailService;
import com.service.scheduling.service.OtcOrderService;
import com.service.scheduling.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;


@Service("hmOtcOrderService")
@Slf4j
public class OtcOrderServiceImpl extends ServiceImpl<OtcOrderMapper, OtcOrder> implements OtcOrderService {

    @Autowired
    private OtcOrderDetailService otcOrderDetailService;

    @Override
    public OtcOrder getMaxPriceOrder(Date someDay) {
        Date someDayStartTime = DateUtil.getDayOfStart(someDay);
        Date someDayEndTime = DateUtil.getDayOfEnd(someDay);
        return baseMapper.selectMaxPriceOrder(someDayStartTime, someDayEndTime);
    }

    @Override
    public OtcOrder getMinPriceOrder(Date someDay) {
        Date someDayStartTime = DateUtil.getDayOfStart(someDay);
        Date someDayEndTime = DateUtil.getDayOfEnd(someDay);
        return baseMapper.selectMaxPriceOrder(someDayStartTime, someDayEndTime);
    }

    @Override
    public OtcOrder getLastDealOrder(Date someDay) {
        Date someDayStartTime = DateUtil.getDayOfStart(someDay);
        Date someDayEndTime = DateUtil.getDayOfEnd(someDay);
        return baseMapper.selectLastOrderByTime(someDayStartTime, someDayEndTime);
    }
}
